/*
 * Copyright (C) 2003-2011 eXo Platform SAS.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Affero General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see<http://www.gnu.org/licenses/>.
 */
package khiem.gwt.demo.gadgetDesktop.client.model;

import java.util.HashMap;

import com.google.gwt.user.client.ui.Composite;

/**
 * Created by The eXo Platform SAS
 * Author : eXoPlatform
 *          exo@exoplatform.com
 * Jun 30, 2011  
 */
public class Gadget extends Composite {
  GadgetClass gadgetclass = null;
  HashMap<UserPref, Object> userprefs = new HashMap<UserPref, Object>();
  
  public Gadget(GadgetClass gc) {
    gadgetclass = gc;
    
    for (int i = 0; i < gc.getUserPrefsCount(); i++) {
      UserPref up = gc.getUserPrefs(i);
      userprefs.put(up, up.getDefaultValue());
    }
  }
  
  public GadgetClass getGadgetClass() {
    return gadgetclass;
  }
  
  public String getTitle() {
    return gadgetclass.getName();
  }
  
  public void refresh() {
    
  }
  
  public Object getUserPrefValue(UserPref up) {
    return userprefs.get(up);
  }
  
  public void setUserPrefValue(UserPref up, Object value) {
    userprefs.put(up, value);
  }
}
